<template>
	<view class="repair-wrap">
		<view class="bg-white position-fixed" style="z-index: 20;width:100%">
			<view class="border-bottom">
				<view style="width: 100%;background: #FFFFFF;">
					<view class="search">
						<input class="search-input" v-model="name" placeholder='请输入您要查询的联系人名称' />
						<view class="btn" @click="getnewList()">
							<text style="color: #FFFFFF;">搜索</text>
						</view>
					</view>
				</view>
				<view class="u-m-t-30" style="width: 89%;margin: 0 auto;">
					<view style="margin-top: -12px;" @click="natov('/privateMsg/news/newsDetail')">
						<view class="content-phone">
							<view style="display:flex;align-items: center;">
								<view class="ml-2">
									<image
										style="width: 60rpx;height: 60rpx;border-radius: 50%; vertical-align: middle;"
										src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/zz.png"></image>
								</view>
								<view style="margin-left: 20rpx;">
									<view>
										<text style="font-size: 18px;color: blue;">物业管理中心各部门电话</text>
									</view>
								</view>
							</view>
							<view class="ml-6">
								<u-icon name="arrow-right" color="#999" size="28"></u-icon>
							</view>

						</view>
					</view>
				</view>
			</view>
		</view>
		
			<view class="nav_item" style="margin-top: 200rpx;">
				<view class="repair-box u-p-r-30" style="display: flex;">
					<view class="u-m-t-20" style="width: 89%;margin: 0 auto;">
						<view v-for="(item,index) in newsData">
							<view style="display: flex;border-bottom: 1px solid #e5e5e5;padding-bottom: 11px;">
								<view style="margin-top: 8px;margin-left: 12px;display:flex;">
									<view>
										<view style="display: flex;">
											<view style="margin-top: 5px;color: #000000;">
												{{item.mail_company}}
											</view>
											<view style="margin-left: 20px;margin-top: 5px;color:#999">
												{{item.mail_name}}
											</view>
										</view>
										<view style="display: flex;align-items: center;margin-top: 10rpx;">
											<image style="width:30rpx;height:30rpx"
												src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/dianhuaben.png"></image>
											<view style="color: #999999;margin-left: 6rpx;">
												<text>电话：{{item.mail_phone}}</text>
											</view>
										</view>
									</view>
								</view>
							</view>
							<view style="float: right;margin-top: -46px;">
								<image style="width: 28px;height: 28px;margin-top: 3px;"
									@click="onCall(item.mail_phone)"
									src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/phone2.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
			</view>
	</view>
</template>

<script>
	import url_config from '@/common/config.js'
	export default {
		data() {
			return {
				view: 1, //1.展示人，2.展示聊天框
				userLoggerInfo: {}, //登录人信息
				newsData: [],
				type: '便民通讯录',
				pageIndex: 1,
				name: null,
				userType: 2,
				myPosition: null,
				reqSource: null
			}
		},
		onShow() {
			this.checkLogin();
			this.checked(1)
		},
		methods: {
			checked(index) {
				this.getnewList()
			},
			// 验证是否登录或实名认证
			checkLogin() {
				let _this = this
				if (uni.getStorageSync('phone')) {
					if (uni.getStorageSync('loginFlag')) {
						if (!uni.getStorageSync('hourseList')) {
							uni.showModal({
								title: '请先进行业主认证',
								showCancel: false,
								confirmText: '确认',
								confirmColor: '#F9A832',
								success: function(res) {
									if (res.confirm) {
										_this.$Router.push({
											path: '/my/address/address'
										})
									}
								}
							});
						}
					} else {
						uni.showModal({
							title: '请先实名认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/homePage1/realName/realName'
									})
								}
							}
						});
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								console.log('a')
								_this.$Router.pushTab({
									path: '/pages/user/user'
								})
							}
						}
					});
				}
			},
			onCall(tel) {
				uni.makePhoneCall({
					phoneNumber: tel //仅为示例
				});
			},
			//获取通讯录列表
			getnewList() {
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.$request.api.getnewesList({
					pageIndex: this.pageIndex,
					org_id: uni.getStorageSync('projectItem').orgId,
					project_id: uni.getStorageSync('projectItem').proId,
					type: '便民通讯录',
					name: this.name,
				}).then(res => {
					if (this.pageIndex == 1) {
						this.newsData = res.data.data.datalist || [];
					} else {
						this.newsData = [...this.newsData, ...res.data.data.datalist];
					}
					uni.hideLoading();
				})
			},
			ckickUserInfo(obj) {
				if (obj.userId == 0) {
					uni.showToast({
						title: "该业主未登录",
						icon: "error"
					})
					return
				}
			},
			natov(url) {
				uni.navigateTo({
					url: url,
				});
			},
			onSearch() {
				this.getList()
			}
		}
	}
</script>


<style lang="scss" scoped>
	.repair-wrap {
		width: 100%;
		height: auto;
		background: #FFFFFF;
		overflow: hidden;
		.repair-box {
			background: #fff;
			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}
	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #427705;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		position: relative;

		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 560rpx;
			top: 50%;
			transform: translateY(-50%);
		}

		.search-input {
			width: 613rpx;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 28rpx;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}
	}

	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #3d7fff;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		width: 100%;
		padding-left: 27px;
		padding-right: 31px;
		// position: fixed;
		z-index: 20;
		background: #FFFFFF;

		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 271px;
			top: 50%;
			transform: translateY(-50%);
		}

		.search-input {
			width: 312px;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 13px;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}

		.btn {
			width: 21%;
			line-height: 33px;
			// border: 1px solid red;
			border: 1px solid linear-gradient(180deg, #76D904 0%, #417505 100%);
			border-radius: 18px;
			text-align: center;
			margin-left: -43px;
			background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		}
	}

	.content-phone {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 0;
	}
</style>